#include "mem.h"

#include "assert.h"

#include <string.h>

static void
simple_test()
{
	printf("enter simple test\n");
	int *p;

	NEW(p);
	*p = 100;
	FREE(p);

	NEW0(p);
	assert(*p == 0);
	FREE(p);

	const int len = 100;
	p = CALLOC(len, sizeof(*p));
	for (int i = 0; i < len; i++)
		p[i] = i;

	const int total = len * sizeof(*p);
	RESIZE(p, total*2);
	for (int i = 0; i < len*2; i++)
		p[i] = i;

	RESIZE(p, total/2);
	for (int i = 0; i < len/2; i++)
		p[i] = i;

	printf("end simple test\n");
}

int main()
{
	simple_test();
	printf("mem test pass\n");
	return 0;
}

